class Solution(object):
    def maxProductAfterCutting(self,length):
        """
        :type length: int
        :rtype: int
        """
        if length == 2:
            return 1
        elif length == 3:
            return 2
        
        product = 1
        if length % 3 == 0:
            for i in range(0,length/3):
                product *= 3
        elif length % 3 == 2:
            for i in range(0,(length-2)/3):
                product *= 3
            product *= 2
        elif length % 3 == 1:
            for i in range(0,(length-4)/3):
                product *= 3
            product *= 4
        return product